home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / M2Crypto / PGP / PublicKeyRing.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2008-10-13  |  2.5 KB  |  84 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from constants import *
  5. from packet import *
  6. from PublicKey import *
  7.  
  8. class PublicKeyRing:
  9.     
  10.     def __init__(self, keyring):
  11.         self._keyring = keyring
  12.         self._userid = { }
  13.         self._keyid = { }
  14.         self._spurious = []
  15.         self._pubkey = []
  16.  
  17.     
  18.     def load(self):
  19.         curr_pub = None
  20.         curr_index = -1
  21.         ps = packet_stream(self._keyring)
  22.         while None:
  23.             pkt = ps.read()
  24.             if pkt is None:
  25.                 break
  26.                 continue
  27.             if isinstance(pkt, public_key_packet):
  28.                 curr_index = curr_index + 1
  29.                 curr_pub = PublicKey(pkt)
  30.                 self._pubkey.append(curr_pub)
  31.                 continue
  32.             if isinstance(pkt, userid_packet):
  33.                 if curr_pub is None:
  34.                     self._spurious.append(pkt)
  35.                 else:
  36.                     curr_pub.add_userid(pkt)
  37.                     self._userid[pkt.userid()] = (curr_pub, curr_index)
  38.             curr_pub is None
  39.             if isinstance(pkt, signature_packet):
  40.                 if curr_pub is None:
  41.                     self._spurious.append(pkt)
  42.                 else:
  43.                     curr_pub.add_signature(pkt)
  44.             curr_pub is None
  45.             self._spurious.append(pkt)
  46.             continue
  47.             ps.close()
  48.             return None
  49.  
  50.     
  51.     def __getitem__(self, id):
  52.         return self._userid[id][0]
  53.  
  54.     
  55.     def __setitem__(self, *args):
  56.         raise NotImplementedError
  57.  
  58.     
  59.     def __delitem__(self, id):
  60.         (pkt, idx) = self._userid[id]
  61.         del self._pubkey[idx]
  62.         del self._userid[idx]
  63.         (pkt, idx) = self._keyid[id]
  64.         del self._keyid[idx]
  65.  
  66.     
  67.     def spurious(self):
  68.         return tuple(self._spurious)
  69.  
  70.     
  71.     def save(self, keyring):
  72.         for p in self._pubkey:
  73.             pp = p.pack()
  74.             keyring.write(pp)
  75.         
  76.  
  77.  
  78.  
  79. def load_pubring(filename = 'pubring.pgp'):
  80.     pkr = PublicKeyRing(open(filename, 'rb'))
  81.     pkr.load()
  82.     return pkr
  83.  
  84.